package com.example.backendmanage.controller;

import com.example.backendmanage.common.AjaxResult;
import com.example.backendmanage.info.Role;
import com.example.backendmanage.mapper.RoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired
    RoleMapper roleMapper;

    @RequestMapping("/pageFind")
    public AjaxResult pageFind(@RequestParam(defaultValue = "") String name,
                               @RequestParam(defaultValue = "") String description,
                               @RequestParam(defaultValue = "") Integer pageIndex,
                               @RequestParam(defaultValue = "") Integer pageSize){
        Integer index=(pageIndex-1)*pageSize;
        List<Role> list=roleMapper.findPage(index,pageSize,name,description);
        HashMap<String,Object> hashMap=new HashMap<>();
        hashMap.put("result",list);
        hashMap.put("total",list.size());
        return AjaxResult.success(hashMap);
    }

}
